<template>
  <transition name="el-zoom-in-center">
    <div class="jsbos-preview-main">
      <div class="jsbos-common-page-header">
        <el-page-header @back="goBack" content="详情" />
        <div class="options">
          <el-button @click="goBack">取 消</el-button>
        </div>
      </div>
      <el-row
        :gutter="15"
        class="main jsbos-row-style"
        :style="{ margin: '0 16px', width: '1200px' }"
      >
        <el-form
          v-loading="loading"
          ref="elForm"
          :model="dataForm"
          size="small"
          label-width="100px"
          label-position="right"
        >
          <template v-if="!loading">
            <el-col :span="24">
              <el-form-item label="封面" prop="cover">
                <UploadImg
                  v-model="dataForm.cover"
                  disabled
                  detailed
                  :fileSize="5"
                  sizeUnit="MB"
                  :limit="1"
                >
                </UploadImg>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="名称" prop="name">
                <p>{{ dataForm.name }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="课程目录" prop="category">
                <p>{{ dataForm.category }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="课程编号" prop="code">
                <p>{{ dataForm.code }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="课程科目" prop="subject">
                <p>{{ dataForm.subject }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="讲师" prop="teacher">
                <p>{{ dataForm.teacher }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="课时" prop="learningPeriod">
                <p>{{ dataForm.learningPeriod }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="课程开发时间" prop="developTime">
                <p>{{ jsbos.dateFormat(dataForm.developTime) }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="适用对象" prop="applyUser">
                <p>{{ dataForm.applyUser }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="课程类别" prop="type">
                <p>{{ dataForm.type }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="有效标志" prop="enabledMark">
                <p>
                  {{ dataForm.enabledMark | dynamicText(enabledMarkOptions) }}
                </p>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="课程介绍" prop="description">
                <p>{{ dataForm.description }}</p>
              </el-form-item>
            </el-col>
          </template>
        </el-form>
      </el-row>
    </div>
  </transition>
</template>
<script>
import request from "@/utils/request";
import PrintBrowse from "@/components/print-browse/index.vue";
import jsbos from "@/utils/jsbos";

export default {
  components: { PrintBrowse },
  props: [],
  data() {
    return {
      visible: false,
      loading: false,
      printBrowseVisible: false,
      printId: "",
      dataForm: {
        id: "",
        cover: [],
        name: "",
        category: "",
        code: "",
        subject: "",
        teacher: "",
        learningPeriod: 0,
        developTime: "",
        applyUser: "",
        type: "",
        enabledMark: "",
        description: "",
        creatorUserId: "",
        creatorTime: "",
        lastModifyUserId: "",
        lastModifyTime: "",
      },
      categoryProps: { children: "children", label: "name", value: "id" },
      enabledMarkOptions: [
        { fullName: "待发布", id: "0" },
        { fullName: "已发布", id: "1" },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    dataInfo(dataAll) {
      let _dataAll = dataAll;
      _dataAll.cover = _dataAll.cover ? JSON.parse(_dataAll.cover) : [];
      this.dataForm = _dataAll;
    },

    goBack() {
      this.$emit("refresh");
    },
    init(id) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true;
          request({
            url: "/api/course/TemsCourseFace/detail/" + this.dataForm.id,
            method: "get",
          }).then((res) => {
            this.dataInfo(res.data);
            this.loading = false;
          });
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.jsbos-row-style {
  padding: 10px 10px 10px 0;

  > .el-row {
    margin: 0 !important;
    padding: 0 16px;
  }

  .el-row:nth-child(0) {
    padding: 0px !important;
  }

  > .el-col {
    padding: 0px !important;

    .el-form-item {
      margin-bottom: -1px !important;
      margin-right: -1px;
      border: 1px solid var(--border-4) !important;
      background-color: var(--light-blue) !important;
    }

    .el-form-item__label {
      line-height: 38px;
      height: 100%;
    }

    .el-form-item__content {
      line-height: 38px;
      padding-left: 20px;
      background-color: var(--white) !important;
      border-left: 1px solid var(--border-4) !important;
    }
  }
}
</style>
